// 测试答题页面题目类型显示功能
const app = getApp();

Page({
  data: {
    questionType: '单选题',
    currentQuestion: null
  },
  
  onLoad: function() {
    this.testQuestionTypeDisplay();
  },
  
  // 测试题目类型显示功能
  testQuestionTypeDisplay: function() {
    console.log('开始测试题目类型显示功能');
    
    // 模拟API返回的不同题目类型数据
    const testCases = [
      { question_type: 'single_choice', expected: '单选题' },
      { question_type: 'multiple_choice', expected: '多选题' },
      { question_type: 'essay', expected: '问答题' },
      { question_type: 'unknown', expected: '单选题' },
      { question_type: null, expected: '单选题' }
    ];
    
    testCases.forEach((testCase, index) => {
      const questionType = this.getQuestionTypeFromAPI(testCase.question_type);
      console.log(`测试用例 ${index + 1}:`);
      console.log(`  输入: ${testCase.question_type}`);
      console.log(`  期望: ${testCase.expected}`);
      console.log(`  实际: ${questionType}`);
      console.log(`  结果: ${questionType === testCase.expected ? '✓ 通过' : '✗ 失败'}`);
    });
  },
  
  // 模拟从API获取题目类型的方法
  getQuestionTypeFromAPI: function(questionType) {
    let displayType = '单选题'; // 默认类型
    
    if (questionType) {
      // 根据API返回的question_type字段设置题目类型
      switch (questionType) {
        case 'single_choice':
          displayType = '单选题';
          break;
        case 'multiple_choice':
          displayType = '多选题';
          break;
        case 'essay':
          displayType = '问答题';
          break;
        default:
          displayType = '单选题';
      }
    }
    
    return displayType;
  }
});